/*
 * DomeMain_View.java
 *
 * Created on 2009年3月22日, 下午8:58
 */
package view;

import model.DomeMainView_Model;
import ucm.ChangeDomeNo_UC;
import ucm.CheckDomeView_UC;
import ucm.StudentCard_UC;

/**
 *
 * @author  马凯
 */
public class DomeMain_View extends javax.swing.JFrame {

    /** Creates new form DomeMain_View */
    public DomeMain_View() {
        initComponents();
        this.setSize(800, 660);
        this.setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        floorImage_La = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        domNo_La = new javax.swing.JLabel();
        floor_CB = new javax.swing.JComboBox();
        floor_La = new javax.swing.JLabel();
        building_CB = new javax.swing.JComboBox();
        buildingView_La = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        building_La = new javax.swing.JLabel();
        domeNo_TF = new javax.swing.JTextField();
        checkPicture_La = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        cid_La = new javax.swing.JLabel();
        cid_TF = new javax.swing.JTextField();
        psw_La = new javax.swing.JLabel();
        psw_TF = new javax.swing.JTextField();
        inject_Bu = new javax.swing.JButton();
        checkPicture_La1 = new javax.swing.JLabel();
        checkPicture_La2 = new javax.swing.JLabel();
        reset_Bu = new javax.swing.JButton();
        note_La = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DOMETARY");

        floorImage_La.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\马凯\\My Documents\\MAP_dormitory.jpg")); // NOI18N
        floorImage_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\马凯\\My Documents\\空白.jpg")); // NOI18N
        jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel1.setBounds(0, 0, 800, 300);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        domNo_La.setText("Dome Number:");
        domNo_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        domNo_La.setBounds(330, 20, 100, 20);
        jLayeredPane1.add(domNo_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        floor_CB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "F1", "F2", "F3", "F4", "F5", "F6" }));
        floor_CB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                floor_CBActionPerformed(evt);
            }
        });
        floor_CB.setBounds(130, 50, 160, 21);
        jLayeredPane1.add(floor_CB, javax.swing.JLayeredPane.PALETTE_LAYER);

        floor_La.setText("Floor:");
        floor_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        floor_La.setBounds(20, 50, 100, 19);
        jLayeredPane1.add(floor_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        building_CB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "L1", "L2", "L3", "L4" }));
        building_CB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                building_CBActionPerformed(evt);
            }
        });
        building_CB.setBounds(130, 20, 160, 21);
        jLayeredPane1.add(building_CB, javax.swing.JLayeredPane.PALETTE_LAYER);

        buildingView_La.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\马凯\\My Documents\\宿舍楼.jpg")); // NOI18N
        buildingView_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        buildingView_La.setBounds(20, 80, 270, 200);
        jLayeredPane1.add(buildingView_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator2.setBounds(310, 0, 10, 300);
        jLayeredPane1.add(jSeparator2, javax.swing.JLayeredPane.PALETTE_LAYER);

        building_La.setText("Building:");
        building_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        building_La.setBounds(20, 20, 100, 20);
        jLayeredPane1.add(building_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        domeNo_TF.setForeground(new java.awt.Color(153, 153, 153));
        domeNo_TF.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
        domeNo_TF.setText("101");
        domeNo_TF.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        domeNo_TF.setBounds(440, 20, 140, 19);
        jLayeredPane1.add(domeNo_TF, javax.swing.JLayeredPane.PALETTE_LAYER);
        checkPicture_La.setBounds(600, 20, 70, 20);
        jLayeredPane1.add(checkPicture_La, javax.swing.JLayeredPane.PALETTE_LAYER);
        jSeparator3.setBounds(310, 50, 490, 2);
        jLayeredPane1.add(jSeparator3, javax.swing.JLayeredPane.PALETTE_LAYER);

        cid_La.setText("Card ID:");
        cid_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        cid_La.setBounds(330, 80, 100, 19);
        jLayeredPane1.add(cid_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        cid_TF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cid_TFKeyPressed(evt);
            }
        });
        cid_TF.setBounds(440, 80, 140, 21);
        jLayeredPane1.add(cid_TF, javax.swing.JLayeredPane.PALETTE_LAYER);

        psw_La.setText("Password:");
        psw_La.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        psw_La.setBounds(330, 110, 100, 19);
        jLayeredPane1.add(psw_La, javax.swing.JLayeredPane.PALETTE_LAYER);
        psw_TF.setBounds(440, 110, 140, 21);
        jLayeredPane1.add(psw_TF, javax.swing.JLayeredPane.PALETTE_LAYER);

        inject_Bu.setText("Ok");
        inject_Bu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inject_BuActionPerformed(evt);
            }
        });
        inject_Bu.setBounds(700, 230, 80, 23);
        jLayeredPane1.add(inject_Bu, javax.swing.JLayeredPane.PALETTE_LAYER);
        checkPicture_La1.setBounds(600, 80, 70, 20);
        jLayeredPane1.add(checkPicture_La1, javax.swing.JLayeredPane.PALETTE_LAYER);
        checkPicture_La2.setBounds(600, 110, 70, 20);
        jLayeredPane1.add(checkPicture_La2, javax.swing.JLayeredPane.PALETTE_LAYER);

        reset_Bu.setText("Reset");
        reset_Bu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reset_BuActionPerformed(evt);
            }
        });
        reset_Bu.setBounds(700, 260, 80, 23);
        jLayeredPane1.add(reset_Bu, javax.swing.JLayeredPane.PALETTE_LAYER);
        note_La.setBounds(330, 260, 360, 20);
        jLayeredPane1.add(note_La, javax.swing.JLayeredPane.PALETTE_LAYER);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        jMenu3.setText("Help");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("About");
        jMenu3.add(jMenuItem1);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(floorImage_La, javax.swing.GroupLayout.DEFAULT_SIZE, 904, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(floorImage_La, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void building_CBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_building_CBActionPerformed
        
}//GEN-LAST:event_building_CBActionPerformed

    private void floor_CBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_floor_CBActionPerformed
        ChangeDomeNo_UC.getInstance(this).run();
    }//GEN-LAST:event_floor_CBActionPerformed

    private void cid_TFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cid_TFKeyPressed
        if ((evt.getKeyCode() == 13 || evt.getKeyCode() == 10)) {
            StudentCard_UC.getInstance(this).run();
        } else {
            //this.cid_TF.setText("");
        }
    }//GEN-LAST:event_cid_TFKeyPressed

    private void inject_BuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inject_BuActionPerformed
        CheckDomeView_UC.getInstance(this).run();
    }//GEN-LAST:event_inject_BuActionPerformed

    private void reset_BuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reset_BuActionPerformed
        this.getViewModel().getCid_TF().setText("");
        this.getViewModel().getPsw_TF().setText("");
        this.getViewModel().getDomeNo_TF().setText("");
        this.getViewModel().getBuilding_CB().setSelectedIndex(0);
        this.getViewModel().getFloor_CB().setSelectedIndex(0);
        this.getViewModel().getCheckPicture_La().setIcon(null);
        this.getViewModel().getCheckPicture_La1().setIcon(null);
    }//GEN-LAST:event_reset_BuActionPerformed

    public DomeMainView_Model getViewModel() {
        DomeMainView_Model dmvm = new DomeMainView_Model();
        dmvm.setBuildingView_La(buildingView_La);
        dmvm.setBuilding_CB(building_CB);
        dmvm.setCheckPicture_La(checkPicture_La);
        dmvm.setCheckPicture_La1(checkPicture_La1);
        dmvm.setCheckPicture_La2(checkPicture_La2);
        dmvm.setDomeNo_TF(domeNo_TF);
        dmvm.setFloor_CB(floor_CB);
        dmvm.setPsw_TF(psw_TF);
        dmvm.setCid_TF(cid_TF);
        dmvm.setNote_La(note_La);
        return dmvm;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new DomeMain_View().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel buildingView_La;
    private javax.swing.JComboBox building_CB;
    private javax.swing.JLabel building_La;
    private javax.swing.JLabel checkPicture_La;
    private javax.swing.JLabel checkPicture_La1;
    private javax.swing.JLabel checkPicture_La2;
    private javax.swing.JLabel cid_La;
    private javax.swing.JTextField cid_TF;
    private javax.swing.JLabel domNo_La;
    private javax.swing.JTextField domeNo_TF;
    private javax.swing.JLabel floorImage_La;
    private javax.swing.JComboBox floor_CB;
    private javax.swing.JLabel floor_La;
    private javax.swing.JButton inject_Bu;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JLabel note_La;
    private javax.swing.JLabel psw_La;
    private javax.swing.JTextField psw_TF;
    private javax.swing.JButton reset_Bu;
    // End of variables declaration//GEN-END:variables
}
